package springboot.http;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class WXGroupChatData {
	private String owner;
	private int chat_has_msg;
	private int member_has_msg;
	private int chat_total;
	private int new_member_cnt;
	private int msg_total;
	private int member_total;
	private int new_chat_cnt;
	
	public WXGroupChatData(String owner, int chat_has_msg, int member_has_msg, int chat_total, int new_member_cnt, int msg_total, int member_total, int new_chat_cnt) {
		this.owner = owner;
		this.chat_has_msg = chat_has_msg;
		this.member_has_msg = member_has_msg;
		this.chat_total = chat_total;
		this.new_member_cnt = new_member_cnt;
		this.msg_total = msg_total;
		this.member_total = member_total;
		this.new_chat_cnt = new_chat_cnt;
	}
	
	public WXGroupChatData(Object o) {
//		避免数据为空的现象
		if (o == null) {
			return;
		}
		JSONObject jsonObject = JSONObject.parseObject(o + "");
		
		this.owner = jsonObject.getString("owner");
		String data = jsonObject.getString("data");
		JSONObject jsonObject2 = JSONObject.parseObject(data);
		
		this.chat_has_msg = jsonObject2.getInteger("chat_has_msg");
		this.member_has_msg = jsonObject2.getInteger("member_has_msg");
		this.chat_total = jsonObject2.getInteger("chat_total");
		this.new_member_cnt = jsonObject2.getInteger("new_member_cnt");
		this.msg_total = jsonObject2.getInteger("msg_total");
		this.member_total = jsonObject2.getInteger("member_total");
		this.new_chat_cnt = jsonObject2.getInteger("new_chat_cnt");
		
	}
	
}
